﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter02.Section1
{
    public class ExampleA
    {
        public ExampleA()
        {
        }
        private string result;
        public string Result
        {
            get { return result; }
        }
        public void Compute()
        {
            L.Vector v1 = new L.Vector(3);
            v1[0] = 1.0;
            v1[1] = 2.0;
            v1[2] = 3.0;

            L.Vector v2 = new L.Vector(3);
            v2[0] = 3.0;
            v2[1] = 2.0;
            v2[2] = 5.0;

            L.Vector v3 = new L.Vector(3);
            v3[0] = 2.0;
            v3[1] = 2.0;
            v3[2] = 4.0;

            L.Vector x = new L.Vector(3);
            x[0] = 0.0;
            x[1] = -1.0;
            x[2] = 0.0;

            L.Vector[] columnVector = new L.Vector[3];
            columnVector[0] = v1;
            columnVector[1] = v2;
            columnVector[2] = v3;

            L.Matrix A = new L.Matrix(columnVector);
            L.Vector b = A * x;

            result += b[0].ToString() + "\r\n";
            result += b[1].ToString() + "\r\n";
            result += b[2].ToString() + "\r\n" + "\r\n";

            L.Vector c = (A * x) - x[0]*v1 - x[1]*v2 - x[2]*v3;

            result += c[0].ToString() + "\r\n";
            result += c[1].ToString() + "\r\n";
            result += c[2].ToString() + "\r\n" + "\r\n";   
        }
    }
}
/*
-3
-2
-5

0
0
0
*/


